package com.wzy.se;

import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

/**
 * 描述  :
 * 创建人:    Wzy
 * 创建时间: 2020-05-24  22:22
 */
public class CollectionsDemo {
    public static void main(String[] args) throws IOException {
//        FileInputStream fileInputStream = new FileInputStream("1.txt");
//        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
//        byte[] bytes = new byte[1024];
//        int len = 0;
//        while ((len = fileInputStream.read(bytes)) != -1) {
//            byteArrayOutputStream.write(bytes, 0, len);
//        }
//        String s = byteArrayOutputStream.toString("utf-8");
//        System.out.println(s);

//        PrintStream printStream = new PrintStream("3.txt","utf-8");
//        printStream.println("helloworld");
//        printStream.close();
        Scanner scanner = new Scanner(new File("3.txt"));
        while (scanner.hasNextLine()) {
            String s = scanner.nextLine();
            System.out.println(s);
        }


    }

    @Test
    public void test() throws IOException {
        File file = new File("3.txt");
        System.out.println("是否存在>>" + file.exists());
        System.out.println("是否文件>>" + file.isFile());
        System.out.println("是否文件夹>>" + file.isDirectory());
        System.out.println("完整路径>>" + file.getPath());
        System.out.println("绝对路径>>" + file.getAbsolutePath());
        System.out.println("标准路径>>" + file.getCanonicalPath());
    }
}
